<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.general.Util"%>
<%
String id = Util.null2String(request.getParameter("id"));
%>
<html>
<head>
<title>我的调查</title>
</head>
<body>
<div id="vote_answer" class="page out">
	<style type="text/css">
		#vote_answer .content{top:0px;bottom:55px;}
		#vote_answer .submit-btn{
			line-height: 35px;
		    border-radius: 5px;
		    color: #fff;
		    background: #017afd;
		    text-align: center;
		    display: none;
	    }
	    
	    #vote_answer .submit-btn-nm{
			line-height: 35px;
		    border-radius: 5px;
		    color: #fff;
		    background: #017afd;
		    text-align: center;
		    display: none;
	    }
	    
		#vote_answer .footer {
		    padding: 10px;
		    height: 55px;
		    box-sizing: border-box;
		    border-top: 1px solid #e7e7e7;
		}
	</style>
	<div class="content">
		<div class="survey_preview_content">
          <form class="surveyform" name="surveyform">
            <input type="hidden" name="votingid" value="<%=id %>" />
            <input type="hidden" name="useranony" value="0" />
	        <div class="survey_body">
	          <div class="survey_title"></div>
			  <div class="survey_countdown" style="display: none;">
			    <span class="countdown_day" style="display: none;"></span>
			    <span class="countdown_hour"></span>
			    <span class="countdown_minute"></span>
			    <span class="countdown_second"></span>
			  </div>
			  <div class="survey_descr" style="padding: 8px; display: none;">
			    <div style="width: 50%; float: left;"><b>发起人:</b></div>
			    <div style="width: 50%; float: left;"><b>开始日期:</b></div>
			    <div style="width: 50%; float: left;"><b>截止日期:</b></div>
                <div style="width: 50%; float: left;"><input type="checkbox" name="" /><b>匿名提交</b></div>     
			  </div>
              <div class="survey_content">
                <div class="survey_question clone" style="display: none;">
                  <div class="survey_quesname">
                    <span class="survey_quesnamedes"></span>
                    <span class="require" style="display: inline;color: red;">*</span>
                    <label class="rules"></label>
                  </div>
                  <div class="survey_options"></div>
                </div>
	          </div>
            </div>
          </form>
        </div>
	</div>
	<div class="footer">
		<div class="submit-btn">提&nbsp;&nbsp;交</div> <div class="submit-btn-nm">匿名提交</div>
	</div>
	<script type="text/javascript">
	$.extend(Vote, {
		buildAnswerPage : function(id){
			var that = this;
			var $page = $("#vote_answer");
			
			function showCountDown(enddatetime){ 
				var now = new Date(); 
				var endDate = new Date(enddatetime); 
				var countdown_leftTime=endDate.getTime()-now.getTime(); 
				var countdown_leftSecond = parseInt(countdown_leftTime/1000); 
				var countdown_year;
				var countdown_day;
				var countdown_hour;
				var countdown_minute;
				var countdown_second;
				if(countdown_leftSecond > 0){ 
					countdown_day = Math.floor(countdown_leftSecond/(60*60*24)); 
					countdown_hour = Math.floor((countdown_leftSecond-countdown_day*24*60*60)/3600); 
					countdown_minute = Math.floor((countdown_leftSecond-countdown_day*24*60*60-countdown_hour*3600)/60); 
					countdown_second = Math.floor(countdown_leftSecond-countdown_day*24*60*60-countdown_hour*3600-countdown_minute*60); 
					
					if(countdown_day !=0 ){
					   $(".countdown_day", $page).html(countdown_day);
					   $(".countdown_day", $page).css("display","");
					}else{
					   $(".countdown_day", $page).css("display","none");
					}
					
					if(countdown_hour <10 ){
					   $(".countdown_hour", $page).html("0"+countdown_hour);
					}else{
					   $(".countdown_hour", $page).html(countdown_hour);
					}
					
				    if(countdown_minute <10 ){
					   $(".countdown_minute", $page).html("0"+countdown_minute);
					}else{
					   $(".countdown_minute", $page).html(countdown_minute);
					}
					
					$(".countdown_minute", $page).css("display","");
				    if(countdown_second <10 ){
					   $(".countdown_second", $page).html("0"+countdown_second);
					}else{
					   $(".countdown_second", $page).html(countdown_second);
					}
				} else if(countdown_leftSecond == 0) {
					window.clearInterval(showCountDownInterval);
				} 
			}
			
			var url = "/mobilemode/apps/e-cology/vote/voteAction.jsp";
			that.ajax(url, {"operate": "getVotingById", "votingid": id}, function(data){
				survey.initSurvey(data.voteinfo.votepages, data.voteinfo.subject, "vote_answer");
				showCountDownInterval = window.setInterval(function() {
					showCountDown(data.voteinfo.enddate.replace(/-/g, "/") + " " + data.voteinfo.endtime);
				}, 1000);
				if(data.voteinfo.isanony){
					$(".submit-btn", $page).css({
						width:"48%",
						float:"left"
					});
					$(".submit-btn-nm", $page).css({
						width:"48%",
						float:"right"
					});
					$(".submit-btn", $page).show();
					$(".submit-btn-nm", $page).show();
				}else{
					$(".submit-btn", $page).show();
				}

			});
			
			$(".submit-btn", $page).click(function() {
				document.surveyform.useranony.value = "0";
				survey.submitsurvey(function(){
					history.go(-1);
					that.refreshList();
				});
			});
			
			$(".submit-btn-nm", $page).click(function() {
				document.surveyform.useranony.value = "1";
				survey.submitsurvey(function(){
					history.go(-1);
					that.refreshList();
				});
			});
		}
	});
	Vote.buildAnswerPage("<%=id%>");
	</script>
</div>
</body>
</html>
